package org.example.leetcode;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description: TODO
 * @Author wyatt
 * @Data 2024/05/14 11:30
 */
public class Solution2244 {

    public static void main(String[] args) {
        Solution2244 solution2244 = new Solution2244();
        int[] tasks = {66,66,63,61,63,63,64,66,66,65,66,65,61,67,68,66,62,67,61,64,66,60,69,66,65,68,63,60,67,62,68,60,66,64,60,60,60,62,66,64,63,65,60,69,63,68,68,69,68,61};
        System.out.println(solution2244.minimumRounds2(tasks));
    }


    public int minimumRounds2(int[] tasks) {
        int sum = 0;
        Map<Integer, Integer> numMap = new HashMap<>();

        for(int i=0;i<tasks.length;i++){
            if(numMap.containsKey(tasks[i])){
                numMap.put(tasks[i], numMap.get(tasks[i]) + 1);
            }else {
                numMap.put(tasks[i], 1);
            }
        }

        for(Integer value : numMap.values()){
            if(value == 1){
                return -1;
            }

//            if(value % 3 == 0){
//                sum += value/3;
//            }else {
//                sum += value/3 + 1;
//            }
            //向上取整
            //向上取整标准操作，x%y只要存在余数，(x+y-1)/y就相当于向上取整了
            sum += (value + 2)/3;
        }
        return sum;
    }

}
